﻿@model Scorpicore.MVC.Models.TopTenUsersViewModel
@{
    ViewBag.Title = "Потребител";
}

@*<h2 class="legend-title">@Model.UserName</h2>*@
    <img class="avater-image" src="@(Model.AvatarUrl)" style="width:200px;height:200px;padding-top:10px;" />
    <div style="display:inline-block; text-align:left;">
        <span class="legend-title" style="font-size:5em;">@Model.UserName</span>
        <br />
        <span class="legend-title">Оставени следи: @Model.Tracks</span>
        <br />
        <span class="legend-title">Регистрирани банкноти: @Model.Banknotes</span>
    </div>
@*<h3>Брой оставени следи: @Model.Tracks</h3>
    <h3>Брой регистрирани банкноти: @Model.Banknotes</h3>*@
<h3 style="text-align:center;">Банкноти свързани с @Model.UserName</h3>
@(Html.Kendo()
    .Grid<Scorpicore.MVC.Models.TopTenBanknoteViewModel>()
    .Name("registered-banknotes")
    .Columns(col =>
        {
            col.Bound(b => b.ImageUrl).ClientTemplate("<img src='#: ImageUrl #' style='width:55px;height:30px' />").Width(50);
            col.Bound(m => m.Letters);
            col.Bound(m => m.SerialNumber);
            col.Bound(m => m.Denomination);
            col.Bound(m => m.LastPlace);
            col.Bound(m => m.Distance);
            col.Bound(m => m.SerialNumber).ClientTemplate(
                @Html.ActionLink("Проследи", "RedirectFromGrid", "Banknote",
                             new
                             {
                                 letters = "#= Letters #",
                                 serialNumber = "#= SerialNumber #"
                             }, null)
                             .ToHtmlString()).Title(" ");
        })
    .DataSource(data =>
        {
            data.Ajax()
                .Model(m => m.Id(b => b.Id))
                .ServerOperation(true)
                .Read("ReadTopTenBanknotes", "TopTen", new { denom = Model, userID = Model.Id.ToString() });
        })
            .Events(events => events.DataBound("dataBound"))
.ClientDetailTemplateId("template")
)

<script>
    function dataBound() {
        this.expandRow(this.tbody.find("tr.k-master-row").first());
    }

    function renderNumber(data) {
        switch (data) {
            case "five": return "5 лв."
                break;
            case "Twenty": return "20 лв."
                break;
            default:
                return "error"
        }
    }

</script>

<script id="template" type="text/x-kendo-template">
    <strong>Следи</strong>
    @(Html.Kendo().Grid<Scorpicore.MVC.Models.TracksInTopTenBanknotesViewModel>()
                    .Name("grid_#=Id#")
                            .Columns(col =>
                {
                    col.Bound(b => b.Place);
                    col.Bound(b => b.User).ClientTemplate("<a href='/Home/GetNameToSearch?name=\\#:User\\#' >\\#:User\\#</a>");
                    col.Bound(m => m.Message);
                    col.Bound(m => m.Date);
                })
                    .DataSource(dataSource => dataSource
                        .Ajax()
                        .PageSize(5)
                        .Read(read => read.Action("ReadTracks", "TopTen", new { Id = "#=Id#" }))
                    )
                    .Pageable()
                    .Sortable()
                    .ToClientTemplate())
</script>



@*@(Html.Kendo().Grid<Scorpicore.MVC.Models.TracksInTopTenBanknotesViewModel>()
        .Name("user-tracks")
        .Columns(c =>
        {
            c.Bound(x => x.Place);
            c.Bound(x => x.User).ClientTemplate("<a href='/Home/GetNameToSearch?name=#:User#' >#:User#</a>");
            c.Bound(x => x.Message);
            c.Bound(x => x.Date);

        })
            .DataSource(data =>
            {
                data.Ajax().Read(act => act.Action("ReadUsersTracks", "Home").Data("GetUserId"));
            }))

    <input type="text" style="display:none" id="txt-id" value="@Model.Id" />
    <script>
        function GetUserId() {
            console.log($("#txt-id").val());
            return {
                id: $("#txt-id").val()
            }
        }

    </script>*@
